package org.mozhu.mysql.learning.hitcounter;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/hit/db")
public class DBHitCounterController {

    @Autowired
    @Qualifier("DBHitCounterService")
    HitCounterService hitCounterService;

    @RequestMapping("/echo")
    @ResponseBody
    public String echo() {
        return "hello world" + System.currentTimeMillis();
    }

    @RequestMapping("/increase")
    @ResponseBody
    public void increase() {
        hitCounterService.increase();
    }

    @RequestMapping("/count")
    @ResponseBody
    public int count() {
        return hitCounterService.count();
    }

    @RequestMapping("/reset")
    @ResponseBody
    public void reset() {
        hitCounterService.reset();
    }

}
